package com.budwk.app.miniapp.common;

import lombok.extern.slf4j.Slf4j;
import org.nutz.dao.DaoException;
import org.nutz.dao.DaoInterceptor;
import org.nutz.dao.DaoInterceptorChain;
import org.nutz.dao.impl.jdbc.NutPojo;
import org.nutz.dao.impl.sql.NutSql;
import org.nutz.dao.sql.DaoStatement;
import org.nutz.ioc.loader.annotation.IocBean;

@Slf4j
public class EquipmentDao implements DaoInterceptor {
    @Override
    public void filter(DaoInterceptorChain chain) throws DaoException {
        DaoStatement st = chain.getDaoStatement();
        if (st instanceof NutPojo) {
            // 如果是dao.insert(user)之类的操作,会进入这个分支
            log.info("aaa.....");
        } else if (st instanceof NutSql) {
            // 如果是自定义SQL,会进入这个分支
          // ((NutSql) st).appendSourceSql("and 1=1");
            log.info(st.getString());
        }
        chain.doChain();//继续下一个拦截器执行
    }
}
